#include<iostream>
#include<cstring>
using namespace std;
int n;
int ans[11]={0,0,0,0,1,2,2,3,3,4,4};
int dfs(int x)
{
	if(x<=10)
	return ans[x];
	else
	{
		if(x%2)
		return dfs(x/2+1)+2;
		else
		return dfs(x/2)+2;
	}
}
int main()
{
	cin>>n;
	cout<<dfs(n);
	return 0;
}